<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>

<?php
$attributes = array(
    'class' => 'control-label',
);
?>

<div class="span9">

    <?php echo get_message(); ?>

    <h2><?php echo $titulo; ?></h2>

    <?php echo form_open(); ?>

    <h3>Buscar:</h3>
    <div class="row-fluid">
        <div class="span3">
            <?php echo form_label('Fecha desde', 'fechaDesde', $attributes); ?>
            <div class="controls input-append">
                <?php
                echo form_input(array('class' => 'span11 date-picker', 'data-date-format' => 'dd/mm/yyyy', 'name' => 'fechaDesde', 'type' => 'text', 'value' => $busqueda['fechaDesde']));
                ?><span class="add-on"><i class="icon-calendar"></i></span>
            </div>
        </div>
        <div class="span3">
            <?php echo form_label('Fecha hasta', 'fechaHasta', $attributes); ?>
            <div class="controls input-append">
                <?php
                echo form_input(array('class' => 'span11 date-picker', 'data-date-format' => 'dd/mm/yyyy', 'name' => 'fechaHasta', 'type' => 'text', 'value' => $busqueda['fechaHasta']));
                ?><span class="add-on"><i class="icon-calendar"></i></span>
            </div>
        </div>
        <div class="span3">
            <div class="control-group">
                <?php echo form_label('&nbsp;', ' ', $attributes); ?>
                <div class="controls">
                    <?php echo form_input(array('class' => 'span11', 'name' => 'submit', 'type' => 'submit', 'value' => 'Buscar', 'class' => 'btn')); ?>
                </div>
            </div>
        </div>
    </div>

    <?php echo form_close(); ?>

    <div class="container-table">
        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-hover table-bordered" id="example">
            <thead>
                <tr>
                    <th>Fecha</th>
                    <th>Fecha del Hecho</th>
                    <th>Tipo</th>
                    <th>Motivo</th>
                    <th>Médico</th>
                    <th>Asesores</th>
                    <th>Acciones</th>
                </tr>
            </thead>
            <tbody>
                <?php
                if (!empty($consultas)) {
                    $color = 'odd';
                    foreach ($consultas as $consulta) {
                        $color = ( $color == 'odd') ? 'even' : 'odd';
                        ?>
                        <tr class="<?php echo $color; ?>">
                            <td><?php echo database_to_normal_date($consulta->fecha); ?></td>
                            <td><?php echo database_to_normal_date($consulta->fechaActoMedico); ?></td>
                            <td><?php echo $consulta->tipo; ?></td>
                            <td><?php echo $consulta->motivo; ?></td>
                            <td><?php echo $consulta->matricula . ' - ' . $consulta->medico; ?></td>
                            <td>
                                <ul>
                                    <?php
                                    foreach ($consulta->asesores as $asesor) {
                                        ?>
                                    <li><?php echo $asesor->nombre . ' ' . $asesor->apellido; ?></li>
                                    <?php
                                    }
                                    ?>
                                </ul>
                            </td>
                            <td>
                                <a class="btn btn-small" href="<?php echo base_url('consultas/editar/' . $consulta->id); ?>"><span class="icon-pencil"></span> Editar</a>
                            </td>
                        </tr>
                        <?php
                    }
                }
                ?>
            </tbody>
        </table>
    </div>
</div>